// pages/ArticleDetail/ArticleDetail.js
var cache=require("../../common/Cache.js").cache;
var dataFilter=require("../../common/DataFilter.js").dataFilter;
var wxParse=require("../../plugs/wxParse/wxParse.js");
// var replacePictures = require("../../common/replacePictures.js");

const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   // console.log(options.id )
   // console.log(app.macauweburl.webApiUrl + "AppArticle/GetDetail")
  
    var id=options.id;

    var that=this;
    wx.request({
      url: app.macauweburl.webApiUrl + "AppArticle/GetDetail", 
      data: {
        ID: id,
      },
      success(res) {
        console.log(res.data)
        console.log('==================================');
        var ArContent = res.data.ArContent.replace(/img {max-width:100%;}/, "");
        // res.data.ArContent = replacePictures.clearInvalidStyle(res.data.ArContent);
        console.log(res.data.ArContent )
        wxParse.wxParse('article', 'html', res.data.ArContent, that, 5);

        console.log("标题是：", res.data.Title);
        wx.setNavigationBarTitle({
          title: res.data.Title
        })   
        
      }
    })



    /*读取对应文章详情*/
   /* cache.get("allArticle",function(result){
      var article=result;
      var articleDetail = dataFilter.getFilter("ID",id,article,1);
      app.console.log("Id:"+id);
      if(articleDetail==undefined){
        return;
      }
      articleDetail.ArContent = articleDetail.ArContent.replace(/img {max-width:100%;}/,"");

      wxParse.wxParse('article', 'html', articleDetail.ArContent, that, 5);

      console.log("标题是：", articleDetail.Title);
      wx.setNavigationBarTitle({
        title: articleDetail.Title
      })   
      //app.console.log(articleDetail);
    });*/


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})